package com.xiaobai.java_core.constructor;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Random;

/**
 * @author wangtw
 * @ClassName Employee
 * @description: 类构造测试实体类
 * @date 2022/5/211:00 PM
 */@Data
public class Employee {

    private static int nextId;

    private Integer id;

    private String name;

    public Employee(Integer id, String name) {
        this.id = id;
        this.name = name;
        System.out.println("构造器执行");
    }

    static {
        Random random = new Random();
        nextId = random.nextInt(100);
        System.out.println("静态初始化块one nextId:" + nextId);
    }

    {
        id = nextId;
        ++ nextId;
        System.out.println("初始化块one nextId:" + nextId);
    }
}
